package com.winit.openapi.ups.controller;

import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;

import com.alibaba.fastjson.JSON;
import com.winit.common.spi.context.CommandContext;
import com.winit.openapi.controller.BaseController;
import com.winit.openapi.model.RequestMsg;
import com.winit.openapi.model.ResponseMsg;
import com.winit.ups.spi.warehouse.WarehouseRegionRelService;
import com.winit.ups.spi.warehouse.command.QueryWarehouseRegionRelCommand;


/**
 * ups  basic Data Controller
 * @author qibin.tang
 *
 */
@Controller
@RequestMapping(value = "/ups/warehouseRegionRel")
public class UpsWarehouseRegionRelController extends BaseController{
    
    
    @Resource
    private WarehouseRegionRelService warehouseRegionRelService;
    
    /**
     * 获取区域配置
     * @param requestMsg
     * @param responseMsg
     * @return
     */
    @RequestMapping(value = "/queryRegion")
    public String queryRegion(@ModelAttribute RequestMsg requestMsg, @ModelAttribute ResponseMsg responseMsg) {
    	QueryWarehouseRegionRelCommand command = JSON.parseObject(requestMsg.getData().toString(), QueryWarehouseRegionRelCommand.class);
    	command.setIsActive("Y");
        command.setCtx(CommandContext.getContext());
        Map<String,String> region = warehouseRegionRelService.queryWarehouseRegion(command);
        responseMsg.setData(region);
        return SUCCESS;
    }

}
